package net.teamix;

import java.io.IOException;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class GetFilter implements Filter {
	FilterConfig config = null;

	public void init(FilterConfig config) throws ServletException {
		this.config = config;
	}

	public void destroy() {
		config = null;
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		
		if (((HttpServletRequest) request).getParameter("msgid")
				!= null) {
			HttpServletRequest httpRequest = (HttpServletRequest) request;
			HttpServletResponse httpResponse = (HttpServletResponse) response;
			HttpSession session = httpRequest.getSession();
			session.setAttribute("translationMsgId", request
					.getParameter("msgid"));
			System.out.println(request.getParameter("msgid"));
			httpResponse.sendRedirect(httpRequest.getContextPath()
					+ "/pages/editnode.jsf");
		} else {
			chain.doFilter(request, response);
		}

	}
}
